package com.design.group;

/**
 * @ClassName Client.java
 * @Description
 * @author Jon
 * @date 2018年6月19日 下午7:53:31
 */
public class Client {
	public static void main(String[] args) {
		Composite root = new Composite();
		Composite branch = new Composite();
		Leaf leaf = new Leaf();
		root.add(branch);
		branch.add(leaf);
	}
	
	/**   
	 * Description  通过递归遍历树		  
	 */ 
	public static void display(Composite root) {
		for (Component component : root.getChildren()) {
			if (component instanceof Leaf) {
				component.doSomething();
			} else {
				display((Composite)component);
			}
		}
	}
}
